package cn.chinaunicom.sdsi.upfc_demp.hyNum.controller;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.chinaunicom.sdsi.frm.base.BaseController;
import cn.chinaunicom.sdsi.frm.sys.R;
import cn.chinaunicom.sdsi.frm.sys.entity.SysStaff;
import cn.chinaunicom.sdsi.frm.sys.entity.SysStaffOrg;
import cn.chinaunicom.sdsi.upfc_demp.demo.controller.UpfDemoTestController;
import cn.chinaunicom.sdsi.upfc_demp.dzgh.entity.DzghApplyEntity;
import cn.chinaunicom.sdsi.upfc_demp.dzgh.service.DzghApplyService;
import cn.chinaunicom.sdsi.upfc_demp.hyNum.entity.HyNum;
import cn.chinaunicom.sdsi.upfc_demp.hyNum.service.HyNumService;
import cn.chinaunicom.sdsi.upfc_demp.jyxx.entity.JyXx;
import cn.chinaunicom.sdsi.upfc_demp.sys.entity.SysDemo;
import net.sf.json.JSONObject;
/**
 * @date 2017-5-10
 * @author 
 * @desc 电子公函申请
 */
@Controller
@RequestMapping("hyNumController")
public class HyNumController extends BaseController{
private final Log log = LogFactory.getLog(UpfDemoTestController.class);
    
    @Autowired
    private HyNumService hyNumService;
    private String elec_id;

    /**
     * 跳转至核验号码详情页面
     */
    @RequestMapping("/hyNumCheck")
    @ResponseBody
    public  JSONObject dzghApplyControllerMain(ModelAndView mv,HttpServletRequest request){
        log.debug("hyNumController.hyNumCheck{}");
        HyNum bean = new HyNum();
        //获取电子公函编码
        String elect_id = request.getParameter("elec_id");
        bean.setElec_id(elect_id);
        bean = hyNumService.selectByPrimaryKey(bean);
        JSONObject obj = new JSONObject();
        obj.element("elec_id", bean.getElec_id());
        obj.element("inDate", bean.getInDate());
        obj.element("num", bean.getNum());
        obj.element("status", bean.getStatus());
        return obj;
    }
    
    
    
    @RequestMapping("/goDatas")
    public ModelAndView goData(ModelAndView mv,HttpServletRequest request) {
        log.info("跳转到DataTable示例页面！");
        String elec_id = request.getParameter("elec_id");
        String selectType = request.getParameter("selectType");
        this.elec_id = elec_id;
        mv.addObject("selectType",selectType);
        mv.setViewName("frm/hyNum/hyNumCheck");
        return mv;
    }

    @ResponseBody
    @RequestMapping("/searchData4Page")
    public JSONObject searchData4Page(HyNum hyNum, Integer start, Integer length,HttpServletRequest request) {
        HyNum bean = new HyNum();
        bean.setElec_id(this.elec_id);
        String num = request.getParameter("num");
        if(!"".equals(num) && num !=null){
            bean.setNum(num);
        }
        return hyNumService.search4Num(bean, start, length);
    }
    
}
